PUT
/
files
/
{id}
Replace file
curl --request PUT \
  --url https://{subdomain}.storage.{region}.nhost.run/v1/files/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'metadata={
  "name": "renamed-file.jpg",
  "metadata": {
    "alt": "Updated image description",
    "category": "profile"
  }
}' \
  --form file=@example-file
{
  "id": "d5e76ceb-77a2-4153-b7da-1f7c115b2ff2",
  "name": "profile-picture.jpg",
  "size": 245678,
  "bucketId": "users-bucket",
  "etag": "\"a1b2c3d4e5f6\"",
  "createdAt": "2023-01-15T12:34:56Z",
  "updatedAt": "2023-01-16T09:45:32Z",
  "isUploaded": true,
  "mimeType": "image/jpeg",
  "uploadedByUserId": "abc123def456",
  "metadata": {
    "alt": "Profile picture",
    "category": "avatar"
  }
}

Authorizations

Authorization
string
header
required

API key to authorize requests.

Path Parameters

id
string
required

Unique identifier of the file to replace

Body

multipart/form-data

File replacement data including new file content and optional metadata

metadata
object

Metadata that can be updated for an existing file.

file
file

New file content to replace the existing file

Response

File successfully replaced

Comprehensive metadata information about a file in storage.

id
string
required

Unique identifier for the file.

Example:

"d5e76ceb-77a2-4153-b7da-1f7c115b2ff2"

name
string
required

Name of the file including extension.

Example:

"profile-picture.jpg"

size
integer
required

Size of the file in bytes.

Example:

245678

bucketId
string
required

ID of the bucket containing the file.

Example:

"users-bucket"

etag
string
required

Entity tag for cache validation.

Example:

"\"a1b2c3d4e5f6\""

createdAt
string<date-time>
required

Timestamp when the file was created.

Example:

"2023-01-15T12:34:56Z"

updatedAt
string<date-time>
required

Timestamp when the file was last updated.

Example:

"2023-01-16T09:45:32Z"

isUploaded
boolean
required

Whether the file has been successfully uploaded.

Example:

true

mimeType
string
required

MIME type of the file.

Example:

"image/jpeg"

uploadedByUserId
string

ID of the user who uploaded the file.

Example:

"abc123def456"

metadata
object

Custom metadata associated with the file.

Example:
{
"alt": "Profile picture",
"category": "avatar"
}